package com.example.webchar.webchar.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * 获取DataSources信息
 *
 * @program: webchars
 * @description
 * @author: 毛叶贵子
 * @create: 2021-08-28 08:30
 **/
@Configuration
public class DataSourcesConfig {

    @Bean(name = "dbOne")
    @ConfigurationProperties(prefix = "spring.datasource.one")
    @Primary
    DataSource dbOne() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "dbTwo")
    @ConfigurationProperties(prefix = "spring.datasource.two")
    DataSource dbTwo() {
        return DataSourceBuilder.create().build();
    }


}
